Ext.QuickTips.init();
LoginWindow = Ext.extend(Ext.Window, {
	title : 'XX系统后台登陆',
	width : 270,
	height : 160,
	closable : false,
	collapsible : true,
	resizable : false,
	defaults : {
		border : false
	},
	buttonAlign : 'center',
	createFormPanel : function() {
		return new Ext.form.FormPanel({
			bodyStyle : 'padding-top:6px',
			defaultType : 'textfield',
			labelAlign : 'right',
			labelWidth : 55,
			labelPad : 0,
			frame : true,
			defaults : {
				allowBlank : false,
				width : 158
			},
			items : [{
				cls : 'user',
				name : 'userBo.userName',
				fieldLabel : '用&nbsp;户&nbsp;名',
				blankText : '帐号不能为空'
			}, {
				cls : 'key',
				name : 'userBo.password',
				fieldLabel : '密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码',
				blankText : '密码不能为空',
				inputType : 'password'
			}, {
				cls : 'key',
				name : 'userBo.randCode',
				id : 'randCode',
				fieldLabel : '验&nbsp;证&nbsp;码',
				width : 80,
				blankText : '验证码不能为空'
			}]
		});
	},
	login : function() {
		this.fp.form.submit({
			waitMsg : '正在登录......',
			url : 'backLogin.action',
			success : function(form, action) {
				window.location.href = basePath + 'back/jsp/backIndex.jsp'
			},
			failure : function(msg, action) {
				var obj = Ext.decode(action.response.responseText);
				if (!obj.success) {
					Ext.Msg.alert("提示", obj.msg);
					rslt = false;
				}
			}
		});
	},
	initComponent : function() {
		LoginWindow.superclass.initComponent.call(this);
		
	
		
		this.fp = this.createFormPanel();
		this.add(this.fp);
		this.addButton('登陆', this.login, this);
		this.addButton('重置', function() {
			this.fp.form.reset();
		}, this);
		var that=this;
		Ext.getBody().on('keypress', function(e){
			if (e.getKey() == e.ENTER) {
					that.fp.form.submit({
					waitMsg : '正在登录......',
					url : 'backLogin.action',
					success : function(form, action) {
						window.location.href = basePath + 'back/jsp/backIndex.jsp'
					},
					failure : function(msg, action) {
						var obj = Ext.decode(action.response.responseText);
						if (!obj.success) {
							Ext.Msg.alert("提示", obj.msg);
							rslt = false;
						}
					}
				});
			}
		},this)
	}
});

Ext.onReady(function() {

	var win = new LoginWindow();
	win.show();
	var bd = Ext.getDom('randCode');
	var bd2 = Ext.get(bd.parentNode);
	if (!Ext.getCmp("randCode").hidden)
		Ext.get(Ext.getDom("randCode").parentNode).createChild({
			tag : "img",
			src : basePath + "back/jsp/randCodeImage.jsp",
			align : "absbottom",
			id : "verifyImage",
			onclick : "this.src='back/jsp/randCodeImage.jsp?'+Math.random();",
			style : "cursor:pointer",
			title : "刷新图片"
		});
});